<?php
$dbhost = "localhost:3307";
$dbuser = 'root';            // mysql用户名
$dbpass = '';          // mysql用户名密码
$conn = mysqli_connect($dbhost, $dbuser, $dbpass);
if (!$conn) {
    die("连接失败");
}

echo '连接成功';
$sql = 'CREATE DATABASE RUNOOB';

$sql1 = "CREATE TABLE runoob_tbl( " .
    "runoob_id INT NOT NULL AUTO_INCREMENT, " .
    "runoob_title VARCHAR(100) NOT NULL, " .
    "runoob_author VARCHAR(40) NOT NULL, " .
    "submission_date DATE, " .
    "PRIMARY KEY ( runoob_id ))ENGINE=InnoDB DEFAULT CHARSET=utf8; ";

mysqli_select_db($conn, 'RUNOOB');

$retval = mysqli_query($conn, $sql1);//创建数据库

if (!$retval) {
    die('数据表创建失败: ' . mysqli_error($conn));
}
echo "数据表创建成功\n";
mysqli_close($conn);
?>
